import service from "../utils/request";

// 登录
export function login(aa, bb) {
    return service.get('/shopBack/user/userLogin', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            userName: aa,
            passWord: bb
        }
    })
}

// 获取轮播图（随机5个）
export function getMainImage() {
    return service.get('/shopBack/mainImage/getMainImage', {
        headers: { 'Content-Type': 'application/json' },
    })
}

// 插入首页轮播图数据
export function insertMainImage(mainImage) {
    return service.get('/shopBack/mainImage/insertMainImage', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            mainImage: mainImage,
        }
    })
}

// 搜索商品,根据商品名称查找商品
export function searchGoodsByGoodsName(bb) {
    return service.get('/shopBack/goodsInfo/searchGoodsByGoodsName', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            goodsName: bb,
        }
    })
}

// 获取用户信息
export function userInfo(aa) {
    return service.get('/shopBack/user/userInfo', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            userName: aa,
        }
    })
}

// 插入商品分类
export function GoodsCategory(cate) {
    return service.get('/shopBack/category/insertCategory', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            goodsCategory: cate,
        }
    })
}

// 获取商品数据
export function getGoodsByRand(num) {
    return service.get('/shopBack/goodsInfo/getGoodsByRand', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            count: num,
        }
    })
}

// 根据轮播图id获取首页轮播图数据
export function getMainImageById(asd) {
    return service.get('/shopBack/mainImage/getMainImageById', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            id: asd,
        }
    
    })
}


// 删除首页轮播图
export function deleteMainImage(zxc) {
    return service.get('/shopBack/mainImage/deleteMainImage', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            id: zxc,
        }
    
    })
}

// 根据商品分类名称获取商品分类
export function getCategoryByName(byname) {
    return service.get('/shopBack/category/getCategoryByName', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            categoryName: byname,
        }
    
    })
}

//删除商品分类
export function deleteCategory(cate) {
    return service.get('/shopBack/category/deleteCategory', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            id: cate,
        }
    })
}

// 修改用户密码
export function changeUserPassWord(userName, passWord) {
    return service.get('/shopBack/user/changeUserPassWord', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            userName: userName,
            passWord: passWord
        }
    })
}

//删除用户
export function deleteUser(cate) {
    return service.get('/shopBack/user/deleteUser', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            userName: cate,
        }
    })
} 

// 获取商品分类
export function getAllCategory() {
    return service.get('/shopBack/category/getAllCategory', {
        headers: { 'Content-Type': 'application/json' },
    })
} 

//获取购物车商品数据
export function getCartInfoByUserName(userName) {
    return service.get('/shopBack/cart/getCartInfoByUserName', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            userName: userName,
        }
    })
}

//删除购物车商品数据
export function deleteCartInfo(goodsId,userName) {
    return service.get('/shopBack/cart/deleteCartInfo', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            goodsId:goodsId,
            userName: userName,
        }
    })
} 

//添加购物地址
export function addGoodsAddress(goodsAddress,userName) {
    return service.get('/shopBack/address/addGoodsAddress', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            goodsAddress:goodsAddress,
            userName: userName,
        }
    })
} 

//获取所有订单
export function getAllGoodsOrder(userName) {
    return service.get('/shopBack/goodsOrder/getAllGoodsOrder', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            userName: userName,
        }
    })
} 

// 根据购物地址编号和用户名获取购物地址
export function getGoodsAddressByIdAndUserName( id,userName) {
    return service.get('/shopBack/address/getGoodsAddressByIdAndUserName', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            id: id,
            userName: userName,
        }
    })
} 

//
export function findGoodsAddress(userName) {
    return service.get('/shopBack/address/findGoodsAddress', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            userName: userName,
        }
    })
} 

// 根据用户名和订单编号删除购买记录
export function deleteGoodsBuyRecordsByUserNameAndBuyRecordId(id,userName) {
    return service.get('/shopBack/goodsOrder/deleteGoodsBuyRecordsByUserNameAndBuyRecordId', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            id:id,
            userName: userName,
        }
    })
} 

// 删除购物地址
export function deleteGoodsAddress(id) {
    return service.get('/shopBack/address/deleteGoodsAddress', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            id:id,
        }
    })
} 

// 根据编号获取商品信息
export function getGoodsById(id) {
    return service.get('/shopBack/goodsInfo/getGoodsById', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            id:id,
        }
    })
} 

//获取余额
export function chargeUserBlance(blance,userName) {
    return service.get('/shopBack/user/chargeUserBlance', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            blance:blance,
            userName:userName,
        }
    })
} 

// 根据用户名查找评价记录
export function findCommentByUserName(userName) {
    return service.get('/shopBack/comment/findCommentByUserName', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            userName:userName,
        }
    })
} 

// 根据商品编号与用户名查找评价记录
export function findCommentByGoodsIdAndUserName(goodsId,userName) {
    return service.get('/shopBack/comment/findCommentByGoodsIdAndUserName', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            goodsId:goodsId,
            userName:userName,
        }
    })
} 

// 根据商品编号查找评价记录
export function findCommentByGoodsId(goodsId) {
    return service.get('/shopBack/comment/findCommentByGoodsId', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            goodsId:goodsId,
        }
    })
} 

// 更新订单状态
export function updateGoodsOrderById(goodsStatus,id) {
    return service.get('/shopBack/goodsOrder/updateGoodsOrderById', {
        headers: { 'Content-Type': 'application/json' },
        params: {
            goodsStatus:goodsStatus,
            id:id,
        }
    })
} 